// types/goods.types.ts

/* 商品评价类型 */
export interface IReview {
    userId: string;
    username: string;
    avatar?: string;
    rating: number;
    content: string;
    images?: string[];
    createTime: string;
    likes?: number;
}

/* 配送选项类型 */
export interface IShippingOption {
    type: 'express' | 'self-pickup' | 'in-store';
    fee: number;
    estimatedDays: number;
    description?: string;
}

/* 商品规格类型 */
export interface ISpecification {
    key: string;
    value: string;
    icon?: string; // 可选的规格图标
}

/* 商品状态联合类型 */
export type GoodsStatus = 'pending' | 'trading' | 'sold' | 'off' | 'reserved';

/* 交易方式联合类型 */
export type TradeType = 'online' | 'offline' | 'both';

/* 商品新旧程度联合类型 */
export type GoodsCondition = 'new' | 'used' | 'refurbished' | 'like-new';

/* 商品主类型 */
export interface IGoods {
    /* 基础信息 */
    id: number;
    type: string;
    category?: string; // 更细分的分类
    name: string;
    brand?: string;
    model?: string;
    sku?: string; // 库存单位
    
    /* 价格库存 */
    price: number;
    originalPrice?: number;
    discount?: number;
    remainCount: number;
    soldCount?: number;
    limitPerUser?: number; // 限购数量
    
    /* 商品详情 */
    description: string;
    specifications: ISpecification[];
    condition: GoodsCondition;
    warranty?: string;
    accessories?: string[]; // 配件信息
    
    /* 多媒体 */
    mainImage: string;
    imageGallery: string[];
    videoUrl?: string;
    vrUrl?: string; // 3D/VR展示
    
    /* 交易信息 */
    status: GoodsStatus;
    tradeType: TradeType;
    shippingOptions?: IShippingOption[];
    returnPolicy?: string;
    paymentMethods?: string[]; // 支持的支付方式
    
    /* 用户交互 */
    viewCount: number;
    favoriteCount?: number;
    rating?: {
        average: number;
        count: number;
        details?: {
            fiveStar?: number;
            fourStar?: number;
            // ...其他星级
        };
    };
    reviews?: IReview[];
    qa?: { // 问答区
        question: string;
        answer: string;
    }[];
    
    /* 卖家信息 */
    sellerId: string;
    sellerName?: string;
    sellerAvatar?: string;
    sellerRating?: number;
    sellerSince?: string; // 卖家入驻时间
    contactMethods: string[];
    businessHours?: string; // 商家营业时间
    
    /* 时间信息 */
    createTime: string;
    updateTime?: string;
    expiryTime?: string;
    promotionEnd?: string; // 促销结束时间
    
    /* 其他 */
    tags?: string[];
    location?: {
        country?: string;
        province: string;
        city: string;
        district?: string;
        address?: string;
        lat?: number; // 纬度
        lng?: number; // 经度
    };
    relatedProducts?: number[];
    recommendedAge?: string; // 推荐使用年龄
    certifications?: string[]; // 认证信息
}

/* 商品列表响应类型 */
export interface IGoodsListResponse {
    total: number;
    page: number;
    pageSize: number;
    items: IGoods[];
    categories?: string[]; // 可用的分类筛选
}

/* 商品创建参数类型 */
export interface IGoodsCreateParams extends Omit<IGoods, 'id' | 'createTime' | 'updateTime'> {
    temporaryId?: string; // 前端临时ID
}

/* 商品更新参数类型 */
export interface IGoodsUpdateParams extends Partial<Omit<IGoods, 'id' | 'createTime'>> {
    id: number;
}

/* 商品筛选参数类型 */
export interface IGoodsFilterParams {
    keyword?: string;
    category?: string;
    minPrice?: number;
    maxPrice?: number;
    condition?: GoodsCondition;
    tradeType?: TradeType;
    location?: string;
    sortBy?: 'price' | 'created' | 'popular';
    sortOrder?: 'asc' | 'desc';
    page?: number;
    pageSize?: number;
}